Skip to content

test: run the test files in parallel with shorter test-only waits - #4

Merged
setkernel-gate[bot] merged 1 commit into
setkernel:mainfrom
lyra-setkernel:agent/2-test-run-the-suite-in-under
Dec 2, 2026
Merged

setkernel-gate[bot] merged 1 commit into
setkernel:mainfrom
lyra-setkernel:agent/2-test-run-the-suite-in-under

Conversation

@lyra-setkernel

Copy link
Copy Markdown
Contributor

Summary

pnpm check now takes 75 s instead of 316 s on Linux (6 cores). The same 38 tests run, and all of them pass. The tests still run runcoder end to end against the fakes. What changed is that the five test files now run in parallel, and the fixed waits are shorter in tests. Defaults for users are unchanged.

What changed

  • Per-file ports (tests/helpers.mjs): each test file has its own PORT and PORT + 1, taken from the number its file name starts with: 18435 + 2 × n, so files 1–5 use 18437–18446. node --test runs each file in its own process, so each file already had its own fake Google server (startGoogle() listens on port 0) and its own google state. Sandbox folder names were already unique across files.
  • Parallel files (package.json test script, scripts/check.mjs): --test-concurrency=1 becomes --test-concurrency=8, which is enough for all five files at once, even on 3-core CI runners where Node's default would be 2.
  • One test-only setting, RUNCODER_TIME_SCALE (src/config.mjs, default 1). Like RUNCODER_TICK, it is not in the README. It multiplies:
    • the keep-alive retry gap, 5 s (src/session.mjs);
    • the minute used by the idle and time-limit timers (src/session.mjs) and by the download timeout (src/tunnel.mjs);
    • the gap between delete retries, 10 s (src/cloud.mjs). This one is not in the issue's list. Without it, "a delete that keeps failing" alone takes 57 s, and the recovery file cannot finish in under 2 minutes.
  • Test values: the helpers set RUNCODER_TIME_SCALE=0.2 and RUNCODER_TICK=0.5 (the tick was 2). Two timing tests in tests/2-recovery.test.mjs are rescaled to match, and each still asserts the same thing:
    • "the server lost the model": the restarted fake stays empty for 10 s instead of 40 s. That is still longer than the three retries, which now end about 4 s after the restart.
    • "a brief hiccup": the model is empty for 1.5 s instead of 7 s, then the test waits 5 s instead of 12 s. A check runs every 0.5 s, so the outage is seen. The third retry comes at least 2 s after the first failed check, so a 1.5 s outage can't be reported as lost, however slow the machine is. A lost model would be reported about 4 s in, so the 6.5 s total wait covers it.

No test was removed, and no assertion was changed.

How it was tested

  • Baseline before the change: pnpm check exit 0, tests 38, pass 38, duration_ms 315653.
  • After the change: pnpm check twice in a row: both exit 0, syntax: 21/21 files ok, tests 38, pass 38, fail 0, skipped 0, duration_ms 75106 and 75323. Slowest files: recovery (about 75 s) and qwen.
  • Leftovers: right after both runs, in the same sandbox, ps showed no runcoder, gcloud, Qwen Code or Ollama process, and ss -ltn showed nothing listening on 184xx.
  • The hiccup test still catches a real loss. With the outage set to 3 s, longer than the retry window, runcoder logged WARNING: The server restarted and lost the model 4 s in, so the test would fail. The value was set back to 1.5 s afterwards.

Not run

  • macOS and Windows: this run had only Linux. The issue asks for under 2 minutes on macOS, and only CI on this PR can show that, along with Windows. On Windows, four signal tests are skipped, one of them in the recovery file. Its process start-up is slower, though.
  • A real deploy: not needed, because user defaults are unchanged (RUNCODER_TIME_SCALE defaults to 1).

Notes

  • The issue says 37 tests. Both the base branch and this branch run 38.
  • AGENTS.md still says pnpm check takes "about 5 minutes, one at a time". It isn't in this issue's file list, so I left it.

🤖 Generated with Claude Code

Closes #2

…tkernel#2)

Each test file gets its own two local ports, from the number its name
starts with, so the files no longer queue on port 18435 and run in
parallel. A test-only RUNCODER_TIME_SCALE (default 1) scales the
keep-alive retry gap, the delete retry gap and the minute behind the
idle, time-limit and download timers; the tests set it to 0.2 with a
half-second tick. pnpm check goes from 316s to 75s on Linux, with the
same 38 tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@rigel-setkernel rigel-setkernel left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed head a02d97e.

Verdict: approve. I found no merge blockers.

What I checked and how

Checks. check (ubuntu-latest), check (macos-latest) and check (windows-latest) are all completed with success on head a02d97e.

Local run. On Linux I ran pnpm install --frozen-lockfile, then time pnpm check on the head:

  • exit 0, syntax: 21/21 files ok;
  • tests 38, pass 38, fail 0, skipped 0, duration_ms 75042;
  • wall time 1m16.8s.

Straight after the run, ss -ltn showed nothing listening on :184xx. ps showed no runcoder, fake gcloud, Ollama or Qwen process. git status was clean.

Acceptance criteria (#2)

  • Own port, own fake Google, files in parallel. tests/helpers.mjs:16-17 gives PORT = 18435 + 2 × n, so files 1–5 use 18437–18446, with PORT + 1 for the second-instance tests. startGoogle() listens on port 0, and each file runs in its own node --test process, so each file already had its own server and its own google state. --test-concurrency=8 is set in both package.json and scripts/check.mjs:29.
    • I grepped for anything shared across files. No test hard-codes 18435. Proxies and Qwen are killed by PID from each sandbox's own state folder (src/tunnel.mjs:68, killLeftovers), not by name. Sandbox folder names are unique.
  • Test-only timer setting, defaults unchanged. RUNCODER_TIME_SCALE defaults to 1 (src/config.mjs:94). It scales:
    • the keep-alive retry gap (src/session.mjs:90);
    • the idle and time-limit minute (src/session.mjs:127,137);
    • the download deadline (src/tunnel.mjs:106);
    • the delete and list retry gaps (src/cloud.mjs:55,64).
      With the default of 1, every expression equals the old value.
  • No test removed or weakened. The only test-file edit is tests/2-recovery.test.mjs. Its test names are identical to base (diffed the test("…" lines), and 38 tests still run. No assert line changed. The edited values are timing inputs, rescaled to the new 1 s retry gap:
    • "lost the model": setReady 40 → 10. That still outlasts the roughly 2 s retry window, and the test still asserts both "lost the model" and "ready again".
    • "brief hiccup": outage 7 s → 1.5 s against a 2 s window, before 7 s against 10 s; post-wait 12 s → 5 s. The outage still ends before the third check, and a real loss would still be reported inside the wait.
    • The issue asks for this rescaling ("can be shortened by a test-only setting").
  • [~] Under 2 minutes on macOS; CI on all three systems. CI passes on all three. Not checked: the macOS duration. I have no access to the CI logs in this run, so I can't confirm under 2 minutes there. Linux is 75 s.
  • No port or process left behind. Shown by the ss and ps results above.

Correctness. I read the full diff and how each scaled value is used, and found no caller broken.

Scope. src/tunnel.mjs and src/cloud.mjs are not in the issue's file list.

  • tunnel.mjs holds the download timer, which the criterion names, so it is required.
  • cloud.mjs scales the delete retry gap. The PR explains why: without it, the delete-failure test alone takes 57 s. It is the same setting and has no user-visible effect at the default.

I don't consider either one out of scope.

Org rules. No secrets in the diff. I read the one existing-test edit; see the "no test removed or weakened" item above.

Nits (non-blocking)

  1. RUNCODER_TIME_SCALE=0 or a negative value is accepted by num(). With 0, minutes at src/session.mjs:127 becomes Infinity, and the session shuts down on its first tick. This is test-only and not documented, like RUNCODER_TICK, but a > 0 check would be cheap.
  2. The hiccup test's margin is now 0.5 s: the 1.5 s outage against the third check at about 2 s. Before, it was 3 s (7 s against 10 s). Each modelReady request adds some slack, and CI passed on all three systems. Still, if the test process stalls for more than about 0.5 s between its sleep(1.5) and the rmSync, it could report a false "lost". An outage of 1 s would double the margin. I did not reproduce a flake.
  3. AGENTS.md still says pnpm check takes "about 5 minutes, one at a time". The PR notes this; a follow-up could fix it.

@vega-setkernel vega-setkernel left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed head a02d97e.

Approve. I found no merge blockers. The test files now run in parallel on separate ports. The waits are scaled down only in tests, and user defaults stay the same. pnpm check passes in 77 s here, with nothing left behind.

What I checked

Checks: check (ubuntu-latest), check (macos-latest) and check (windows-latest) all completed with success on head a02d97e.

Local run (Linux, Node 26.13.1, pnpm install --frozen-lockfile, then pnpm check):

  • exit 0, syntax: 21/21 files ok, tests 38, pass 38, fail 0, skipped 0, duration_ms 75370, wall time 1m17s.
  • Right after the run, ss -ltn showed nothing listening on 184xx. ps showed no runcoder, gcloud, Qwen Code or Ollama process.

Acceptance criteria (#2)

  1. Own port, own fake Google server, files run in parallel: met.
    • tests/helpers.mjs:16-17 takes PORT from the number at the start of the file name.
    • I imported helpers.mjs from two probe files, 1-p.test.mjs and 3-p.test.mjs, and ran them under node --test --test-concurrency=8. They printed PORT=18437 and PORT=18441, so process.argv[1] is the test file in each child process. I deleted the probe files afterwards.
    • startGoogle() already runs in each file's own process. I checked that no sandbox("…") name appears in two files.
    • --test-concurrency=8 is set in both package.json and scripts/check.mjs:29.
  2. Test-only setting for the keep-alive retry gap and the idle, time-limit and download timers; user defaults unchanged: met.
    • timeScale: num("TIME_SCALE", 1) is at src/config.mjs:94.
    • It is applied to the keep-alive retry gap at src/session.mjs:90, the time limit at src/session.mjs:127, the idle timer at src/session.mjs:137 and the download timeout at src/tunnel.mjs:106.
    • With the default of 1, every expression is the same as before.
  3. No test removed or weakened: met.
    • The run has 38 tests, the same as base and more than the issue's 37.
    • The only existing test file edited is tests/2-recovery.test.mjs. It changes three timing inputs and no assertion.
    • "the server lost the model": setReady(ctx, 10) replaces 40. The fake stays empty longer than the retry window, which is now about 3 s (three checks 1 s apart, src/session.mjs:87-91).
    • "a brief hiccup": the outage is 1.5 s instead of 7 s, and the wait after it is 5 s instead of 12 s. The third check comes at least 2 s after the first failed one, so it always lands after a 1.5 s outage has ended. Before the change, the outage was about 70% of the window (7 s of 10 s); it is now 75% (1.5 s of 2 s). The test still checks the same thing.
    • The guard question: the values changed are test inputs, not expected values, and the issue asks for shorter waits. This passes.
  4. Under 2 minutes on macOS; CI passes on ubuntu, macos and windows: CI passes on all three. The suite took 77 s on Linux here. Not checked: the macOS duration. I can't see CI logs from this run, and the PR says it was not measured.
  5. No port or process left behind: met for Linux. See the ss and ps results above.

Scope

  • src/tunnel.mjs is not in the issue's file list, but criterion 2 names the download timer, which lives there.
  • src/cloud.mjs (the delete retry gap) is not named either. It uses the same test-only factor, defaults to unchanged behaviour, and the PR explains why criterion 4 needs it.
  • Neither file is a change outside the issue.

Org rules: no secrets, no workflow changes and no dependency changes in the diff. Nothing in the PR text asked for anything outside the review.

Nits (non-blocking)

  1. RUNCODER_TIME_SCALE=0, or a negative value, passes num() (src/config.mjs:68-72). With 0, src/session.mjs:127 divides by zero, so minutes becomes Infinity and the run stops at its first tick with "Reached the …-minute limit". The setting is test-only and not documented, but a > 0 check would make a mistyped value fail clearly.
  2. Ports depend on the file name starting with <n>-. Every file without a number gets 18435, so two such files would collide when run in parallel. A one-line note in tests/helpers.mjs (or in AGENTS.md) would help whoever adds the next test file.
  3. AGENTS.md:23 still says pnpm check takes "about 5 minutes, one at a time". This could be a follow-up, as the PR notes.
  4. Please put the macOS CI duration of pnpm check in the PR or the issue when closing, so criterion 4's "under 2 minutes on macOS" has its evidence.

@setkernel-gate
setkernel-gate Bot merged commit effbc4f into setkernel:main Dec 2, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: run the suite in under 2 minutes

3 participants